package com.gitee.wsl.compose.richtext

//import androidx.compose.runtime.Composable
//import androidx.compose.runtime.LaunchedEffect
//import androidx.compose.runtime.mutableStateOf
//import androidx.compose.runtime.getValue
//import androidx.compose.runtime.setValue
//import androidx.compose.runtime.remember
//import coil3.compose.AsyncImagePainter
//import coil3.compose.rememberAsyncImagePainter
//import com.gitee.wsl.annotation.ExperimentalApi
//import com.gitee.wsl.compose.image.ImageData
//import com.gitee.wsl.compose.image.ImageLoader
//import com.gitee.wsl.compose.text.edit.annotation.ExperimentalRichTextApi
//
//
//@ExperimentalRichTextApi
//object Coil3ImageLoader : ImageLoader {
//
//    @OptIn(ExperimentalApi::class)
//    @Composable
//    override fun load(model: Any): ImageData? {
//        val painter = rememberAsyncImagePainter(model = model)
//
//        var imageData by remember {
//            mutableStateOf<ImageData?>(null)
//        }
//
//        LaunchedEffect(painter.state) {
//            painter.state.collect { state ->
//                imageData =
//                    if (state is AsyncImagePainter.State.Success)
//                        ImageData(
//                            painter = state.painter
//                        )
//                    else
//                        null
//            }
//        }
//
//        return imageData
//    }
//
//}
